#!/bin/bash
#

#检测MySQL IO/SQL线程状态
#判断脚本是否有参数
if [ -z $1 ]; then
    echo "帮助（请输入参数）：$0 <IO|SQL>"
    exit 29
fi

user=root
password=CCC.929.z

# 根据参数截取IO、SQL线程的状态
status=$(mysql -u${user} -p${password} -e "show slave status\G" 2> /dev/null | grep -w "Slave_$1_Running" | awk '{print $2}')

case ${status} in
    Yes)
	echo "1"
	;;
    *)
	echo "0"
	;;
esac
